#ifndef CALCULATORWIDGET_H
#define CALCULATORWIDGET_H

#include <QWidget>
#include <QLabel>
#include <QGridLayout>
#include <QPushButton>
#include "calculator.h" // 包含calculator.h中重命名的BigDecimal类

class CalculatorWidget : public QWidget
{
    Q_OBJECT

public:
    CalculatorWidget(QWidget *parent = nullptr);
    ~CalculatorWidget();

private slots:
    void onDigitPressed();
    void onOperatorPressed();
    void onDecimalPressed();
    void onSignPressed();
    void onEqualsPressed();
    void onClearPressed();

private:
    QLabel *displayLabel;
    QVector<QPushButton*> digitButtons;
    BigDecimal firstOperand;
    BigDecimal currentNumber;
    QString currentOperation;
    bool isInputtingNumber;
    QString pendingOperator;
    QString currentExpression; // 记录当前运算表达式
    bool newNumberExpected;    // 标记是否需要新数字输入

    void setupUi();
    void updateDisplay();
    void performOperation();

};
#endif // CALCULATORWIDGET_H
